package com.zmn.plat.common.dictionary;

import com.zmn.common.dto.VtDTO;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 周期
 *
 * @author xiangjunming
 * @since 2020/06/23 14:56:30
 */
public enum WeekEnum {

    /**
     * values
     */
    MON(1, "周一"),
    TUES(2, "周二"),
    WED(3, "周三"),
    THUR(4, "周四"),
    FRI(5, "周五"),
    SAT(6, "周六"),
    SUN(0, "周日"),
    ;

    private Integer value;
    private String text;

    WeekEnum(Integer value, String text) {
        this.value = value;
        this.text = text;
    }

    public Integer getValue() {
        return value;
    }

    public String getText() {
        return text;
    }

    public static WeekEnum of(Integer value) {
        if (value == null) {
            return null;
        }
        switch (value) {
            case 1:
                return MON;
            case 2:
                return TUES;
            case 3:
                return WED;
            case 4:
                return THUR;
            case 5:
                return FRI;
            case 6:
                return SAT;
            case 0:
                return SUN;
            default:
                return null;
        }
    }

    public static String getText(Integer value) {
        WeekEnum of = of(value);
        return of == null ? null : of.getText();
    }

    public static List<VtDTO> listVtDTO(){
        List<VtDTO> collect = Stream.of(values()).map(item -> new VtDTO(item.getValue(), item.getText()))
                .collect(Collectors.toList());
        return collect;
    }
}
